package service

import (
	"guliedu/model"
	"guliedu/repository"
	"mime/multipart"
)

type IEduTeacherService interface {
	SelectByID(id string) (*model.EduTeacher, error)
	SelectAll() ([]*model.EduTeacher, error)
	Delete(id string) error
	SelectAllCount() (int64, error)
	SelectPage(pageSize int, page int, name string, level int) ([]*model.EduTeacher, error)
	Insert(t *model.EduTeacher) error
	Update(t *model.EduTeacher) error
	UploadProfile(file multipart.File, fileSize int64) (string, int)
	SelectIndexHotTeacher() ([]model.EduTeacher, error)
	SelectFrontTeacherInfoList(page int, pageSze int) ([]model.EduTeacher, error)
	CacheTeacher([]model.EduTeacher) error
	GetCacheTeacher() []model.EduTeacher
}

func NewIEduTeacherService() IEduTeacherService {
	return &EduTeacherService{EduRepository: repository.NewIEduTeacherRepository()}
}

type EduTeacherService struct {
	EduRepository repository.IEduTeacherRepository
}

func (e *EduTeacherService) SelectByID(id string) (*model.EduTeacher, error) {
	return e.EduRepository.SelectByID(id)
}

func (e *EduTeacherService) SelectAll() ([]*model.EduTeacher, error) {
	return e.EduRepository.SelectAll()
}

func (e *EduTeacherService) Delete(id string) error {
	return e.EduRepository.Delete(id)
}

func (e *EduTeacherService) SelectAllCount() (int64, error) {
	return e.EduRepository.SelectAllCount()
}

func (e *EduTeacherService) SelectPage(pageSize int, page int, name string, level int) ([]*model.EduTeacher, error) {
	return e.EduRepository.SelectPage(pageSize, page, name, level)
}

func (e *EduTeacherService) Insert(t *model.EduTeacher) error {
	return e.EduRepository.Insert(t)
}

func (e *EduTeacherService) Update(t *model.EduTeacher) error {
	return e.EduRepository.Update(t)
}

func (e *EduTeacherService) UploadProfile(file multipart.File, fileSize int64) (string, int) {
	return e.EduRepository.UploadProfile(file, fileSize)
}

func (e *EduTeacherService) SelectIndexHotTeacher() ([]model.EduTeacher, error) {
	return e.EduRepository.SelectIndexHotTeacher()
}

func (e *EduTeacherService) SelectFrontTeacherInfoList(page int, pageSze int) ([]model.EduTeacher, error) {
	return e.EduRepository.SelectFrontTeacherInfoList(page, pageSze)
}

func (e *EduTeacherService) CacheTeacher(teachers []model.EduTeacher) error {
	return e.EduRepository.CacheTeacher(teachers)
}

func (e *EduTeacherService) GetCacheTeacher() (teachers []model.EduTeacher) {
	return e.EduRepository.GetCacheTeacher()
}
